package com.k136.controller;


import com.github.pagehelper.PageInfo;
import com.k136.entity.Add;
import com.k136.entity.Brand;
import com.k136.entity.R;
import com.k136.service.AddService;
import com.k136.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

/**
 * TODO 类
 *
 * @author LiuTai
 * @version 1.00
 * @Date 2024/7/29
 */
@RestController
@RequestMapping("/add")
@CrossOrigin(origins = "*")
public class AddController {
    @Resource
    private AddService addService;
    @Resource
    private BrandService brandService;
    @RequestMapping("{brandId}/{pageNo}")
    public R list(@PathVariable("brandId") Integer brandId, @PathVariable("pageNo") Integer pageNo){
        return R.ok(addService.selAdd(brandId,pageNo,2));
    }
    @RequestMapping(value = "/insert")
    public String insert(Add add){
        if (addService.insAdd(add)){
            return "index";
        }else {
            return "add";
        }
    }
}
